const query=require("../db/mysql")


class Listshop{
    getList=async (ctx)=>{
        const {id,keyword}=ctx.query
        console.log(id)
        let sql=`select * from shop where 1=1 `

        if(id){
            sql+=`and id="${id}" `
        }

        if(keyword){
            sql+=`and shopname like "%${keyword}%" `
        }

        const data=await query(sql)

        ctx.body={
            data:data
        }
    }


    getDetail=async (ctx)=>{    
        const {id}=ctx.params
        console.log(ctx.query)
        let sql=`select * from shop where id="${id}" `
        const data=await query(sql)
        ctx.body={
            data:data
        }
    }
}


module.exports=new Listshop()